<?php 
session_start();
require_once('../include/connect.inc.php'); 	
if($_SESSION['sess_id'] <> session_id()){
?>
 <SCRIPT LANGUAGE="JavaScript">
			alert("กรุณาเข้าสู่ระบบให้ถูกต้องตามขั้นตอน...!");
			location="login.php";
</script>
<?php }?>
<?php
if($_REQUEST['topic_id'] != "") //ถ้า ค่า admin_id ไม่เท่ากับค่าว่างเปล่า
{
$del_id = $_REQUEST['subject_id'];
$sql_del = "delete from  tb_topic where topic_id = '$topic_id';";
mysql_query($sql_del) or die(mysql_error());
$admin_id = $rs['topic_id'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Model Test Program</title>
<link rel="stylesheet" type="text/css" href="../template/template_style_wood.css">
</head>

<body>
<div id="menu"><div><img src="../images/icon-m.png" /></div>
<div id="menulinks">
		<a  href="../person_tea.php">ข้อมูลส่วนตัว</a>
		<a href="../tea_edit.php">เปลี่ยนรหัสผ่านใหม่</a>
        
        <a class="active"   href="show_subject.php">จัดการรายวิชา</a>
		<a href="../teacher_test.php">จัดการข้อสอบ</a>
        <a href="../teacher_tests.php">จัดการชุดข้อสอบ</a>
        <a  href="../agree_set.php">กำหนดสิทธิ์</a>
		<a href="../exam/tea_chack.php">ตรวจสอบคะแนน</a>
        <a href="../news/manage_news.php">ประกาศข่าวสาร</a>
        <a href="../problem/send_problem.php">แสดงความคิดเห็น</a>
        <a href="../logout.php">ออกจากระบบ</a>
		</div></div>           
 <div id="p3">    
<div id="header"></div>
   <div id="page"><div id="p1">คุณ<?php echo $_SESSION['teacher_name'];?><hr/>
<form name="form1" id="form1" method="post" action="show_topic.php">
<table  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left">จัดการหัวข้อหลัก</th>
        <th align="right"><a href="insert_topic.php?subject_id=<? echo "$subject_id";?>"><img src="../images/add.png" border="0" /></a></th>
      </tr>
    </table>
<table id="table" width="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th width="80" align="center">ลำดับที่</th>
    <th width="179" align="center">หัวข้อหลัก</th>
    <th width="50" align="center">ลบ</th>
    <th width="50" align="center">แก้ไข</th>
  </tr>
<?php
  		 $query = query("SELECT * FROM tb_topic where subject_id='".$_GET[subject_id]."' ");
		$count=1;
		while ($rs = fetch_array($query)) {
			$topic_id=$rs['topic_id'];
		    $topic_detail = $rs['topic_detail'];
?>
  <tr>
    <td align="center"><?php echo $count;echo ".";?></td>
    <td><? echo "$topic_detail";?></td>
    <td align="center">
      <script language="JavaScript">
		function Conf<?=$rs["topic_id"]; ?>(object) {
		if (confirm("ยืนยันการลบรายวิชา") ==true) {
		return true;
		}
		return false;
		}
          </script>
          <a href="show_topic.php?topic_id=<?=$rs["topic_id"];?>&subject_id=<? echo "$subject_id";?>"
      onclick="return Conf<?=$rs["topic_id"]; ?>(this)"> <img src="../images/delete1.png" border="0" /></a></td>
    <td align="center"><a href="edit_topic.php?subject_id=<? echo "$subject_id";?>&topic_id=<?=$topic_id;?>"><img src="../images/edit.png" border="0" /></a></td>
  </tr>
  <? $count++; } ?>
</table>
</form><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
    </div>
    </div>
<div id="footer"></div>
</div>
</body>
</html>
